<template>
  <div class="container">
    <div class="package-card bg-white hd-shadow">

      <van-row>
        <van-search
                v-model="value"
                placeholder="请输入搜索关键词"
                show-action
                @search="onSearch"
        >
          <div slot="action" @click="onSearch">搜索</div>
        </van-search>

      </van-row>

      <van-cell-group>
        <van-cell
                v-for="(item, index) in newlist" :key="index"
                :title="item.company_name"
                icon="location-o"
                :value="item.mobile"
                :label="item.address"
                @click="info(item)"
        />
      </van-cell-group>
    </div>
  </div>
</template>

<script>
export default {
  name: 'funeral_home',
  data () {
    return {
      value: '',
      newlist: []
    }
  },
  methods: {
    init () {
      this.$http({
        fun: 'ctcfuneralhome',
        requestType: 'get',
        cb: res => {
          console.log(res)
          this.newlist = res.results
          this.newlist.forEach(item => {
            console.log('111')
          })
        }
      })
    },
    info (item) {
      console.log(item.id)
      window.location.href = 'tel:' + item.mobile
      // this.$router.push({
      //   name: 'news_detail',
      //   query: {
      //     'id': item.id
      //   }
      // })
    },
    onSearch () {
      console.log('search')
      console.log(this.value)
      this.$http({
        fun: 'ctcfuneralhome',
        company_name: this.value,
        cb: res => {
          console.log(res)
          this.newlist = res.results
          this.newlist.forEach(item => {
            console.log('111')
          })
        }
      })
    }
  },

  mounted () {
    this.init()
  }
}
</script>

<style src="./index.css" scoped>
</style>
